<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.17"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>CANopenNode: CANopenNode</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
  $(document).ready(function() { init_search(); });
/* @license-end */
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">CANopenNode
   </div>
  </td>
   <td>        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
</td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.17 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
var searchBox = new SearchBox("searchBox", "search",false,'Search');
/* @license-end */
</script>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(document).ready(function(){initNavTree('index.html',''); initResizable(); });
/* @license-end */
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="PageDoc"><div class="header">
  <div class="headertitle">
<div class="title">CANopenNode </div>  </div>
</div><!--header-->
<div class="contents">
<div class="textblock"><p>CANopenNode is free and open source CANopen protocol stack.</p>
<p>CANopen is the internationally standardized (EN 50325-4) (<a href="http://can-cia.org/standardization/technical-documents">CiA301</a>) higher-layer protocol for embedded control system built on top of CAN. For more information on CANopen see <a href="http://www.can-cia.org/">http://www.can-cia.org/</a></p>
<p>CANopenNode is written in ANSI C in object-oriented way. It runs on different microcontrollers, as standalone application or with RTOS. Linux implementation with CANopen master functionalities is included.</p>
<p>Variables (communication, device, custom) are ordered in CANopen Object Dictionary and are accessible from both: C code and from CANopen network.</p>
<p>CANopenNode homepage is <a href="https://github.com/CANopenNode/CANopenNode">https://github.com/CANopenNode/CANopenNode</a></p>
<h1>Characteristics </h1>
<h2>CANopen</h2>
<ul>
<li><a href="https://www.can-cia.org/can-knowledge/canopen/device-architecture/">Object Dictionary</a> offers clear and flexible organisation of any variables.</li>
<li><a href="https://www.can-cia.org/can-knowledge/canopen/network-management/">NMT</a> slave to start, stop, reset device. Simple NMT master.</li>
<li><a href="https://www.can-cia.org/can-knowledge/canopen/error-control-protocols/">Heartbeat</a> producer/consumer error control.</li>
<li><a href="https://www.can-cia.org/can-knowledge/canopen/pdo-protocol/">PDO</a> linking and dynamic mapping for fast exchange of process variables from Object Dictionary.</li>
<li><a href="https://www.can-cia.org/can-knowledge/canopen/sdo-protocol/">SDO</a> expedited, segmented and block transfer for service access to all Object Dictionary variables.</li>
<li><a href="https://www.can-cia.org/can-knowledge/canopen/sdo-protocol/">SDO</a> client.</li>
<li><a href="https://www.can-cia.org/can-knowledge/canopen/special-function-protocols/">Emergency</a> producer/consumer.</li>
<li><a href="https://www.can-cia.org/can-knowledge/canopen/special-function-protocols/">Sync</a> producer/consumer.</li>
<li><a href="https://www.can-cia.org/can-knowledge/canopen/special-function-protocols/">Time-stamp</a> protocol producer/consumer.</li>
<li><a href="https://www.can-cia.org/can-knowledge/canopen/cia305/">LSS</a> master and slave, LSS fastscan.</li>
<li><a href="https://www.can-cia.org/can-knowledge/canopen/cia309/">CANopen gateway</a>, CiA309-3 Ascii command interface for NMT master, LSS master and SDO client.</li>
<li>CANopen Safety, EN 50325-5 "PDO like" communication in safety-relevant networks</li>
</ul>
<h2>Other</h2>
<ul>
<li><a href="#device-support">Suitable for 16-bit microcontrollers and above</a></li>
<li><a href="#flowchart-of-a-typical-canopennode-implementation">Multithreaded, real-time</a></li>
<li><a href="#object-dictionary-editor">Object Dictionary editor</a></li>
<li>Non-volatile storage for Object Dictionary variables.</li>
<li><a href="#power-saving">Power saving possible</a></li>
<li><a href="https://github.com/CANopenNode/CANopenNode/issues/111">Bootloader possible</a> (for firmware update)</li>
</ul>
<h1>Documentation, support and contributions </h1>
<p>Documentation with <a class="el" href="md_doc_gettingStarted.html">Getting started</a>, <a class="el" href="md_doc_LSSusage.html">LSS usage</a> and <a class="el" href="md_doc_traceUsage.html">Trace usage</a> is in <code>doc</code> directory. Code is documented in header files. Running <a href="http://www.doxygen.nl/">doxygen</a> in project base directory will produce complete html documentation. Just open CANopenNode/doc/html/index.html in the browser. Alternatively browse documentation <a href="https://canopennode.github.io/CANopenSocket/">online</a>.</p>
<p>Report issues on <a href="https://github.com/CANopenNode/CANopenNode/issues">https://github.com/CANopenNode/CANopenNode/issues</a></p>
<p>Older and still active discussion group is on Sourceforge <a href="http://sourceforge.net/p/canopennode/discussion/387151/">http://sourceforge.net/p/canopennode/discussion/387151/</a></p>
<p>Contributions are welcome. Best way to contribute your code is to fork a project, modify it and then send a pull request. Some basic formatting rules should be followed: Linux style with indentation of 4 spaces. There is also a <code>codingStyle</code> file with example and a configuration file for <code>clang-format</code> tool.</p>
<h1>Flowchart of a typical CANopenNode implementation </h1>
<div class="fragment"><div class="line">                            -----------------------</div>
<div class="line">                           |     Program start     |</div>
<div class="line">                            -----------------------</div>
<div class="line">                                       |</div>
<div class="line">                            -----------------------</div>
<div class="line">                           |     CANopen init      |</div>
<div class="line">                            -----------------------</div>
<div class="line">                                       |</div>
<div class="line">                            -----------------------</div>
<div class="line">                           |     Start threads     |</div>
<div class="line">                            -----------------------</div>
<div class="line">                                 |     |     |</div>
<div class="line">             --------------------      |      --------------------</div>
<div class="line">            |                          |                          |</div>
<div class="line"> -----------------------    -----------------------    -----------------------</div>
<div class="line">| CAN receive thread    |  | Timer interval thread |  | Mainline thread       |</div>
<div class="line">|                       |  |                       |  |                       |</div>
<div class="line">| - Fast response.      |  | - Realtime thread with|  | - Processing of time  |</div>
<div class="line">| - Detect CAN ID.      |  |   constant interval,  |  |   consuming tasks     |</div>
<div class="line">| - Partially process   |  |   typically 1ms.      |  |   in CANopen objects: |</div>
<div class="line">|   messages and copy   |  | - Network synchronized|  |    - SDO server,      |</div>
<div class="line">|   data to target      |  | - Copy inputs (RPDOs, |  |    - Emergency,       |</div>
<div class="line">|   CANopen objects.    |  |   HW) to Object Dict. |  |    - Network state,   |</div>
<div class="line">|                       |  | - May call application|  |    - Heartbeat.       |</div>
<div class="line">|                       |  |   for some processing.|  |    - LSS slave        |</div>
<div class="line">|                       |  | - Copy variables from |  | - May cyclically call |</div>
<div class="line">|                       |  |   Object Dictionary to|  |   application code.   |</div>
<div class="line">|                       |  |   outputs (TPDOs, HW).|  |                       |</div>
<div class="line"> -----------------------    -----------------------    -----------------------</div>
<div class="line"> </div>
<div class="line">              -----------------------</div>
<div class="line">             | SDO client (optional) |</div>
<div class="line">             |                       |</div>
<div class="line">             | - Can be called by    |</div>
<div class="line">             |   external application|</div>
<div class="line">             | - Can read or write   |</div>
<div class="line">             |   any variable from   |</div>
<div class="line">             |   Object Dictionary   |</div>
<div class="line">             |   from any node in the|</div>
<div class="line">             |   CANopen network.    |</div>
<div class="line">              -----------------------</div>
<div class="line"> </div>
<div class="line">              -----------------------</div>
<div class="line">             | LSS Master (optional) |</div>
<div class="line">             |                       |</div>
<div class="line">             | - Can be called by    |</div>
<div class="line">             |   external application|</div>
<div class="line">             | - Can do LSS requests |</div>
<div class="line">             | - Can request node    |</div>
<div class="line">             |   enumeration         |</div>
<div class="line">              -----------------------</div>
</div><!-- fragment --><h1>File structure </h1>
<ul>
<li><b>301/</b> - CANopen application layer and communication profile.<ul>
<li><b><a class="el" href="CO__config_8h.html" title="Configuration macros for CANopenNode.">CO_config.h</a></b> - Configuration macros for CANopenNode.</li>
<li><b><a class="el" href="CO__driver_8h.html" title="Interface between CAN hardware and CANopenNode.">CO_driver.h</a></b> - Interface between CAN hardware and CANopenNode.</li>
<li><b><a class="el" href="CO__ODinterface_8h.html" title="CANopen Object Dictionary interface.">CO_ODinterface.h</a>/.c</b> - CANopen Object Dictionary interface.</li>
<li><b><a class="el" href="CO__Emergency_8h.html" title="CANopen Emergency protocol.">CO_Emergency.h</a>/.c</b> - CANopen Emergency protocol.</li>
<li><b><a class="el" href="CO__HBconsumer_8h.html" title="CANopen Heartbeat consumer protocol.">CO_HBconsumer.h</a>/.c</b> - CANopen Heartbeat consumer protocol.</li>
<li><b><a class="el" href="CO__NMT__Heartbeat_8h.html" title="CANopen Network management and Heartbeat producer protocol.">CO_NMT_Heartbeat.h</a>/.c</b> - CANopen Network management and Heartbeat producer protocol.</li>
<li><b><a class="el" href="CO__PDO_8h.html" title="CANopen Process Data Object protocol.">CO_PDO.h</a>/.c</b> - CANopen Process Data Object protocol.</li>
<li><b><a class="el" href="CO__SDOclient_8h.html" title="CANopen Service Data Object - client protocol.">CO_SDOclient.h</a>/.c</b> - CANopen Service Data Object - client protocol (master functionality).</li>
<li><b><a class="el" href="CO__SDOserver_8h.html" title="CANopen Service Data Object - server protocol.">CO_SDOserver.h</a>/.c</b> - CANopen Service Data Object - server protocol.</li>
<li><b><a class="el" href="CO__SYNC_8h.html" title="CANopen Synchronisation protocol.">CO_SYNC.h</a>/.c</b> - CANopen Synchronisation protocol (producer and consumer).</li>
<li><b><a class="el" href="CO__TIME_8h.html" title="CANopen Time-stamp protocol.">CO_TIME.h</a>/.c</b> - CANopen Time-stamp protocol.</li>
<li><b><a class="el" href="CO__fifo_8h.html" title="FIFO circular buffer.">CO_fifo.h</a>/.c</b> - Fifo buffer for SDO and gateway data transfer.</li>
<li><b><a class="el" href="crc16-ccitt_8h.html" title="Calculation of CRC 16 CCITT polynomial.">crc16-ccitt.h</a>/.c</b> - Calculation of CRC 16 CCITT polynomial.</li>
</ul>
</li>
<li><b>303/</b> - CANopen Recommendation<ul>
<li><b><a class="el" href="CO__LEDs_8h.html" title="CANopen Indicator specification (CiA 303-3 v1.4.0)">CO_LEDs.h</a>/.c</b> - CANopen LED Indicators</li>
</ul>
</li>
<li><b>304/</b> - CANopen Safety.<ul>
<li><b><a class="el" href="CO__SRDO_8h.html" title="CANopen Safety Related Data Object protocol.">CO_SRDO.h</a>/.c</b> - CANopen Safety-relevant Data Object protocol.</li>
<li><b><a class="el" href="CO__GFC_8h.html" title="CANopen Global fail-safe command protocol.">CO_GFC.h</a>/.c</b> - CANopen Global Failsafe Command (producer and consumer).</li>
</ul>
</li>
<li><b>305/</b> - CANopen layer setting services (LSS) and protocols.<ul>
<li><b><a class="el" href="CO__LSS_8h.html" title="CANopen Layer Setting Services protocol (common).">CO_LSS.h</a></b> - CANopen Layer Setting Services protocol (common).</li>
<li><b><a class="el" href="CO__LSSmaster_8h.html" title="CANopen Layer Setting Service - master protocol.">CO_LSSmaster.h</a>/.c</b> - CANopen Layer Setting Service - master protocol.</li>
<li><b><a class="el" href="CO__LSSslave_8h.html" title="CANopen Layer Setting Service - slave protocol.">CO_LSSslave.h</a>/.c</b> - CANopen Layer Setting Service - slave protocol.</li>
</ul>
</li>
<li><b>309/</b> - CANopen access from other networks.<ul>
<li><b><a class="el" href="CO__gateway__ascii_8h.html" title="CANopen access from other networks - ASCII mapping (CiA 309-3 DS v3.0.0)">CO_gateway_ascii.h</a>/.c</b> - Ascii mapping: NMT master, LSS master, SDO client.</li>
</ul>
</li>
<li><b>extra/</b><ul>
<li><b><a class="el" href="CO__trace_8h.html" title="CANopen trace object for recording variables over time.">CO_trace.h</a>/.c</b> - CANopen trace object for recording variables over time.</li>
</ul>
</li>
<li><b>example/</b> - Directory with basic example, should compile on any system.<ul>
<li><b><a class="el" href="CO__driver__target_8h.html" title="Linux socketCAN specific definitions for CANopenNode.">CO_driver_target.h</a></b> - Example hardware definitions for CANopenNode.</li>
<li><b>CO_driver_blank.c</b> - Example blank interface for CANopenNode.</li>
<li><b>CO_OD.h/.c</b> - CANopen Object dictionary. Automatically generated files.</li>
<li><b>main_blank.c</b> - Mainline and other threads - example template.</li>
<li><b>Makefile</b> - Makefile for example.</li>
<li><b>IO.eds</b> - Standard CANopen EDS file, which may be used from CANopen configuration tool. Automatically generated file.</li>
<li>_ <b>project.xml</b> - XML file contains all data for CANopen Object dictionary. It is used by <em>Object dictionary editor</em> application, which generates other files.</li>
<li>_ <b>project.html</b> - <em>Object dictionary editor</em> launcher.</li>
</ul>
</li>
<li><b>socketCAN/</b> - Directory for Linux socketCAN interface.<ul>
<li><b><a class="el" href="CO__driver__target_8h.html" title="Linux socketCAN specific definitions for CANopenNode.">CO_driver_target.h</a></b> - Linux socketCAN specific definitions for CANopenNode.</li>
<li><b>CO_driver.c</b> - Interface between Linux socketCAN and CANopenNode.</li>
<li><b><a class="el" href="CO__error_8h.html" title="CANopenNode Linux socketCAN Error handling.">CO_error.h</a>/.c</b> - Linux socketCAN Error handling object.</li>
<li><b><a class="el" href="CO__error__msgs_8h_source.html">CO_error_msgs.h</a></b> - Error definition strings and logging function.</li>
<li><b><a class="el" href="CO__Linux__threads_8h.html" title="Helper functions for implementing CANopen threads in Linux.">CO_Linux_threads.h</a>/.c</b> - Helper functions for implementing CANopen threads in Linux.</li>
<li><b><a class="el" href="CO__OD__storage_8h.html" title="CANopen Object Dictionary storage object for Linux SocketCAN.">CO_OD_storage.h</a>/.c</b> - Object Dictionary storage object for Linux SocketCAN.</li>
<li><b>CO_main_basic.c</b> - Mainline for socketCAN (basic usage).</li>
</ul>
</li>
<li><b>doc/</b> - Directory with documentation<ul>
<li><b>CHANGELOG.md</b> - Change Log file.</li>
<li><b>deviceSupport.md</b> - Information about supported devices.</li>
<li><b>gettingStarted.md, LSSusage.md, traceUsage.md</b> - Getting started and usage.</li>
<li><b>index.html</b> - Soft link to html/md_README.html.</li>
<li><b>html</b> - Directory with documentation - must be generated by Doxygen.</li>
</ul>
</li>
<li><b><a class="el" href="CANopen_8h.html" title="Main CANopenNode file.">CANopen.h</a>/.c</b> - Initialization and processing of CANopen objects.</li>
<li><b>codingStyle</b> - Example of the coding style.</li>
<li>**.clang-format** - Definition file for the coding style.</li>
<li><b>Doxyfile</b> - Configuration file for the documentation generator <em>doxygen</em>.</li>
<li><b>Makefile</b> - Makefile for Linux socketCAN.</li>
<li><b>canopend</b> - Executable for Linux, build with <code>make</code>.</li>
<li><b>LICENSE</b> - License.</li>
<li><b>README.md</b> - This file.</li>
</ul>
<h1>Object dictionary editor </h1>
<p>Object Dictionary is one of the most important parts of CANopen. Its implementation in CANopenNode is quite outdated and there are efforts to rewrite it. Anyway, currently it is fully operational and works well.</p>
<p>To customize the Object Dictionary it is necessary to use external application: <a href="https://github.com/robincornelius/libedssharp">libedssharp</a>. It can be used in Windows or Linux with Mono.</p>
<p>Please note: since rearrangement in directory structure it is necessary to manually update CO_OD.c file - it must include: <code><a class="el" href="CO__driver_8h.html" title="Interface between CAN hardware and CANopenNode.">301/CO_driver.h</a></code>, <code>CO_OD.h</code> and <code><a class="el" href="CO__SDOserver_8h.html" title="CANopen Service Data Object - server protocol.">301/CO_SDOserver.h</a></code>.</p>
<h1>Device support </h1>
<p>CANopenNode can run on many different devices. Each device (or microcontroller) must have own interface to CANopenNode. CANopenNode can run with or without operating system.</p>
<p>It is not practical to have all device interfaces in a single project. For that reason CANopenNode project only includes interface to Linux socketCAN. Interfaces to other microcontrollers are in separate projects. See <a class="el" href="md_doc_deviceSupport.html">deviceSupport.md</a> for list of known device interfaces.</p>
<h1>Some details </h1>
<h2>RTR</h2>
<p>RTR (remote transmission request) is a feature of CAN bus. Usage of RTR is not recommended for CANopen and it is not implemented in CANopenNode.</p>
<h2>Self start</h2>
<p>Object <b>0x1F80</b> from Object Dictionary enables the NMT slaves to start automatically or allows it to start the whole network. It is specified in DSP302-2 standard. Standard allows two values for slaves for object 0x1F80:</p><ul>
<li>Object 0x1F80, value = <b>0x8</b> - "NMT slave shall enter the NMT state
  Operational after the NMT state Initialization autonomously (self starting)"</li>
<li>Object 0x1F80, value = <b>0x2</b> - "NMT slave shall execute the NMT service
  start remote node with node-ID set to 0"</li>
</ul>
<h2>Error control</h2>
<p>When node is stated (in NMT operational state), it is allowed to send or receive Process Data Objects (PDO). If Error Register (object 0x1001) is set, then NMT operational state is not allowed.</p>
<h2>Power saving</h2>
<p>All CANopen objects calculates next timer info for OS. Calculation is based on various timers which expire in known time. Can be used to put microcontroller into sleep and wake at the calculated time.</p>
<h1>Change Log </h1>
<p>See <a class="el" href="md_doc_CHANGELOG.html">CHANGELOG.md</a></p>
<h1>License </h1>
<p>Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at</p>
<p><a href="http://www.apache.org/licenses/LICENSE-2.0">http://www.apache.org/licenses/LICENSE-2.0</a></p>
<p>Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. </p>
</div></div><!-- PageDoc -->
</div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="footer">Generated on Sat Sep 19 2020 10:03:21 for CANopenNode by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.17 </li>
  </ul>
</div>
</body>
</html>
